package imse.team0.processors;

import imse.team0.orderws.data.OrderType;
import org.apache.camel.Exchange;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Evgenia
 * Date: 5/22/12
 * Time: 12:16 PM
 * To change this template use File | Settings | File Templates.
 */
public class CheckSOAPReceivedMessage {

    public void buildOrder(Exchange exchange) {
        OrderType order = (OrderType) exchange.getIn().getBody(List.class).get(0);
        OrderType.OrderItem orderItem = (OrderType.OrderItem)order.getOrderItem().get(0);
        System.out.println("----+++++print gregorian calendar value " + order.getTimestamp());
        System.out.println("----+++++print order id " + orderItem.getId());
        System.out.println("----+++++print item name " + orderItem.getName());
        System.out.println("----+++++print order quantity " + orderItem.getQty());
        System.out.println("----+++++print client id " + order.getClientID());
        OrderType newOrder = new OrderType();
        newOrder.setTimestamp(order.getTimestamp());
        newOrder.setClientID(order.getClientID());
        List<OrderType.OrderItem> items = newOrder.getOrderItem();
        items.add(orderItem);
        exchange.getIn().setBody(newOrder);
        //exchange.getOut().setBody(order);

    }
}
